package com.intellagric.controller.module.ift_equipment;

import com.intellagric.common.pojo.LayuiDataGridResult;
import com.intellagric.common.pojo.ResponseMessage;
import com.intellagric.pojo.IftEquipmentAssociate;
import com.intellagric.service.iftmonitor.ift_equipment.EquipmentAssociateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.UUID;

/**
 * @Author: zhy
 * @email: 1269679946@qq.com
 * @Date: 2018/10/18
 * @DESC： 采集设备关联设备管理
 */
@Controller
public class EquipmentAssociateController {

    @Autowired
    private EquipmentAssociateService equipmentAssociateService;

    /**
     * 添加采集设备关联设备信息
     * @Param equipmentAssociate
     * @return ResponseMessage
     */
    @RequestMapping("/equipment/associate/add")
    @ResponseBody
    public ResponseMessage add(IftEquipmentAssociate equipmentAssociate) {
        equipmentAssociate.setId(UUID.randomUUID().toString().replaceAll("-",""));
        return equipmentAssociateService.addEquipmentAssociate(equipmentAssociate);
    }
    
    
    /**
     * 删除采集设备关联设备信息
     * @Param id
     * @return ResponseMessage
     */
    @RequestMapping("/equipment/associate/delete")
    @ResponseBody
    public ResponseMessage delete(String id) {
        return equipmentAssociateService.deleteEquipmentAssociate(id);
    }
    
    /**
     * 修改采集设备关联设备信息
     * @Param equipmentAssociate
     * @return ResponseMessage
     */
    @RequestMapping("/equipment/associate/edit")
    @ResponseBody
    public ResponseMessage edit(IftEquipmentAssociate equipmentAssociate) {
        return equipmentAssociateService.editEquipmentAssociate(equipmentAssociate);
    }
    
    /**
     * 查询采集设备关联设备信息
     * @return IftEquipmentAssociate
     */
    @RequestMapping("/equipment/associate/{id}")
    @ResponseBody
    public IftEquipmentAssociate get(@PathVariable String id) {
        return equipmentAssociateService.getEquipmentAssociateById(id);
    }

    /**
     * 查询采集设备关联设备信息
     * @return IftEquipmentAssociate
     */
    @RequestMapping("/equipment/associate/query")
    @ResponseBody
    public LayuiDataGridResult getByVO(String equipmentId) {
        return equipmentAssociateService.getEquipmentAssociateByVo(equipmentId);
    }
    
    /**
     * 查询采集设备关联设备信息列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/equipment/associate/list")
    @ResponseBody
    public LayuiDataGridResult getList() {
        return equipmentAssociateService.getEquipmentAssociate();
    }
    
    /**
     * 分页查询采集设备关联设备信息列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/equipment/associate/page")
    @ResponseBody
    public LayuiDataGridResult getPage(int limit,int rows) {
        return equipmentAssociateService.getEquipmentAssociate(limit,rows);
    }

}
